Skip to content

sofima-stitch-fix-20261201 - #265

Merged
trautmane merged 5 commits into
newsolverfrom
sofima-stitch-fix-20261201
Dec 3, 2026
Merged

trautmane merged 5 commits into
newsolverfrom
sofima-stitch-fix-20261201

Conversation

@trautmane

@trautmane trautmane commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Apply SOFIMA stitch fixes during the SOFIMA import

Some w61 slabs had stitching problems in individual layers. Those layers were restitched with SOFIMA, and each slab's 3D SOFIMA field was then recomputed. This PR adds an optional step to the SOFIMA import that applies the restitched tile transforms before the slab's 3D displacement field is appended.

Usage

Add --stitchFixUri (or stitchFixUri in the pipeline JSON's sofima block):

"sofima": {
  "sofimaFieldUri": "gs://janelia-spark-test/SOFIMA/warp_flow_precomputed_261127",
  "stitchFixUri": "gs://janelia-spark-test/SOFIMA/stitch_fix_261130",
  "targetStackSuffix": "_s"
}

The URI points at a directory holding a manifest.json, which lists the fixed layers, and one _layer/transforms.json per layer. Each transforms.json maps a tile's mipmap level 0 imageUrl to a replacement spec list: a tile-local DisplacementFieldTransform (scale=20.0, one z-slice per tile in a Precomputed volume) followed by a translation-only AffineModel2D.

Slabs without fixes, and runs without stitchFixUri, import exactly as before.

How a fixed layer is changed

For each tile in a fixed layer:

before:  [
  ExponentialFunctionOffsetTransform, 
  (StageCreepCorrectionTransform), 
  AffineModel2D
]

after:   [
  ExponentialFunctionOffsetTransform, 
  DisplacementFieldTransform (2D stitch fix), 
  AffineModel2D (translation)
]

The import then appends the 3D DisplacementFieldTransform as usual. A StageCreepCorrectionTransform, which appears in early layers, is replaced along with the affine. The restitching worked on tiles with only the exponential offset applied, so the stitch fix field already accounts for creep.

…nd any StageCreepCorrectionTransform (if one exists). The stitch fix data was not built with any creep correction transform.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Empty replacement transform lists can remove affine and creep corrections without installing a stitch fix, allowing stacks with incorrect tile placement to be saved.

3 open issues
What changed in this PR

Adds optional SOFIMA stitch corrections during import, applying restitched tile transforms before the slab’s 3D displacement field.

Changes:

  • Adds stitchFixUri configuration.
  • Loads and checks per-layer replacement transforms.
  • Applies stitch fixes while retaining the initial exponential transform and replacing affine and creep corrections.
File Description
render-ws-java-client/​src/​main/​java/​org/​janelia/​render/​client/​parameter/​SofimaParameters.java Adds stitch-fix configuration and slab-name extraction.
render-ws-java-client/​src/​main/​java/​org/​janelia/​render/​client/​multisem/​SofimaStitchFix.java Loads, validates, and applies layer-specific stitch fixes.
render-ws-java-client/​src/​main/​java/​org/​janelia/​render/​client/​multisem/​ImportSofimaClient.java Integrates stitch fixes before adding the 3D field.

Review effort: Balanced

…ust now be exactly [DisplacementFieldTransform, AffineModel2D], both as leaf transforms. Otherwise loading fails with a message naming the image URL and the file. Because this happens during loading, a bad entry stops the import before the target stack is even created.
@trautmane
trautmane requested a review from minnerbe December 2, 2026 20:40
@trautmane
trautmane merged commit f28e8ad into newsolver Dec 3, 2026
2 checks passed
@trautmane
trautmane deleted the sofima-stitch-fix-20261201 branch December 3, 2026 13:22
@trautmane

Copy link
Copy Markdown
Collaborator Author

@minnerbe - please continue to post any review comments here and I will address them in a separate pull request. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants